<template>
	<view class="index_container">
		<!-- <image src="" mode=""></image> -->
		<view class="btn" @click="choosePic">
			上传
		</view>
	</view>
</template>

<script setup>
	const choosePic = () => {
	uni.chooseImage({
		success: function (res) {
				console.log('选择本地图片到内存中',res);
				res.tempFilePaths.forEach(v=>{
					uni.uploadFile({
						url:'http://192.168.1.5:3000/api/upload',
						filePath:v,
						name:'file',
						success:(upRes)=>{
							let rezult=JSON.parse(upRes.data)
							// 上传内存图片到服务器成功
							if(rezult.status===200){
							console.log('upRes:',rezult.data.id);
							}
						}
						
					})
				})
			}
	})
	}
</script>

<style scoped >
	.index_container {
		min-height: 100%;
		padding: 30rpx;
		box-sizing: border-box;
	}
	.btn{
		padding: 15rpx  20rpx;
		background: #31D49D;
		color: #fff;
		text-align: center;
		display: inline-block;
	}
	.flex{
		/* display: flex; */
	}
</style>